import 'dart:convert';
import 'dart:ui';

import 'package:star_author/generated/json/backflow_list_item_entity.g.dart';
import 'package:star_author/generated/json/base/json_field.dart';

@JsonSerializable()
class BackflowListItemEntity {
  int? id;
  String? number;
  String? status;
  int? expired_evaluation_duration_with_count_down;
  @JSONField(name: "immediate_support")
  bool? immediateSupport;
  int? stock;
  @JSONField(name: "created_at")
  String? createdAt;
  @JSONField(name: "updated_at")
  String? updatedAt;
  @JSONField(name: "evaluated_price")
  dynamic evaluatedPrice;
  @JSONField(name: "confirmed_price")
  dynamic confirmedPrice;
  @JSONField(name: "onsale_at")
  dynamic onsaleAt;
  @JSONField(name: "approved_evaluation_count")
  int? approvedEvaluationCount;
  @JSONField(name: "expired_at")
  dynamic expiredAt;
  @JSONField(name: "user_id")
  int? userId;
  @JSONField(name: "store_code")
  String? storeCode;
  @JSONField(name: "price_range")
  List<dynamic>? priceRange;
  @JSONField(name: "rejected_reason")
  String? rejectedReason;
  String? comment;
  @JSONField(name: "finished_at")
  dynamic finishedAt;
  @JSONField(name: "backflow_received_address")
  String? backflowReceivedAddress;
  @JSONField(name: "money_for_owner")
  dynamic moneyForOwner;
  @JSONField(name: "immediate_discount_price")
  String? immediateDiscountPrice;
  @JSONField(name: "normal_discount_price")
  String? normalDiscountPrice;
  int? limited;
  String? strategy;
  @JSONField(name: "tenders_count")
  int? tendersCount;
  @JSONField(name: "rate_for_tender")
  String? rateForTender;
  @JSONField(name: "preview_confirmed_price")
  dynamic previewConfirmedPrice;
  @JSONField(name: "back_code")
  String? backCode;
  @JSONField(name: "rate_for_hitter")
  String? rateForHitter;
  @JSONField(name: "evaluation_limited")
  int? evaluationLimited;
  @JSONField(name: "take_down_at")
  dynamic takeDownAt;
  bool? recyclable;
  @JSONField(name: "is_offline_saling")
  bool? isOfflineSaling;
  @JSONField(name: "expired_evaluated_at")
  String? expiredEvaluatedAt;
  @JSONField(name: "is_expired_evaluation")
  bool? isExpiredEvaluation;
  @JSONField(name: "evaluated_at")
  String? evaluatedAt;
  @JSONField(name: "need_tenders_count")
  int? needTendersCount;
  @JSONField(name: "already_tenders_count")
  int? alreadyTendersCount;
  @JSONField(name: "rate_for_deducting_immediate_competitive_strategy")
  String? rateForDeductingImmediateCompetitiveStrategy;
  @JSONField(name: "send_back_at")
  dynamic sendBackAt;
  @JSONField(name: "first_evaluation")
  bool? firstEvaluation;
  bool? sonance;
  @JSONField(name: "express_logs_id")
  int? expressLogsId;
  BackflowListItemGoods? goods;
  dynamic logistic;
  @JSONField(name: "back_logistic")
  dynamic backLogistic;
  @JSONField(name: "back_address")
  dynamic backAddress;
  dynamic rating;
  @JSONField(name: "previous_max_tender_price")
  int? previousMaxTenderPrice;
  @JSONField(name: "is_immediate")
  bool? isImmediate;
  @JSONField(name: "is_special_offer")
  bool? isSpecialOffer;
  @JSONField(name: "can_onsale_again")
  bool? canOnsaleAgain;
  @JSONField(name: "can_evaluated_again")
  bool? canEvaluatedAgain;
  @JSONField(name: "can_onsale_from_back")
  bool? canOnsaleFromBack;
  @JSONField(name: "klone_id")
  dynamic kloneId;
  @JSONField(name: "original_id")
  dynamic originalId;
  @JSONField(name: "tender_price")
  dynamic tenderPrice;
  bool? shopped;
  @JSONField(name: "can_onsale_from_closed")
  bool? canOnsaleFromClosed;
  String? illustration;
  @JSONField(name: "rate_for_deducting")
  String? rateForDeducting;
  String? cover;

  BackflowListItemEntity();

  factory BackflowListItemEntity.fromJson(Map<String, dynamic> json) =>
      $BackflowListItemEntityFromJson(json);

  Map<String, dynamic> toJson() => $BackflowListItemEntityToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }

  static List<BackflowListItemEntity> fromJsonList(List jsonRes) {
    return jsonRes.map((e) => BackflowListItemEntity.fromJson(e)).toList();
  }
}

@JsonSerializable()
class BackflowListItemGoods {
  int? id;
  String? description;
  @JSONField(name: "created_at")
  String? createdAt;
  @JSONField(name: "updated_at")
  String? updatedAt;
  dynamic weight;
  dynamic texture;
  dynamic circle;
  int? count;
  @JSONField(name: "process_status")
  String? processStatus;
  String? certificate;
  String? specification;
  String? title;
  String? category;
  String? category_prefix;
  @JSONField(name: "category_id")
  int? categoryId;
  String? serial;
  BackflowListItemGoodsCover? cover;

  BackflowListItemGoods();

  factory BackflowListItemGoods.fromJson(Map<String, dynamic> json) =>
      $BackflowListItemGoodsFromJson(json);

  Map<String, dynamic> toJson() => $BackflowListItemGoodsToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}

@JsonSerializable()
class BackflowListItemGoodsCover {
  String? url;
  int? width;
  int? height;

  //这个属性不需要序列化和反序列化
  @JSONField(serialize: false, deserialize: false)
  Size? size;

  BackflowListItemGoodsCover();

  factory BackflowListItemGoodsCover.fromJson(Map<String, dynamic> json) =>
      $BackflowListItemGoodsCoverFromJson(json);

  Map<String, dynamic> toJson() => $BackflowListItemGoodsCoverToJson(this);

  @override
  String toString() {
    return jsonEncode(this);
  }
}
